home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
626-650
/
641
/
tlog
/
monthtot1.tlog
< prev
next >
Wrap
Text File
|
1995-03-15
|
3KB
|
94 lines
/* AREXX report for TLog that prints the total monthly distances */
/* Start at the begining of the data base and keep getting the next record */
/* and add up any distances until you get to the end. Right now the only */
/* way to tell you're at the end is when nextrec result is lastrec */
OPTIONS RESULTS
/* setup the port to tlog */
ADDRESS 'TLOG'
/* Initialize the a table of monthly totals */
total.JAN = 0;
total.FEB = 0;
total.MAR = 0;
total.APR = 0;
total.MAY = 0;
total.JUN = 0;
total.JUL = 0;
total.AUG = 0;
total.SEP = 0;
total.OCT = 0;
total.NOV = 0;
total.DEC = 0;
total.YEAR = 0;
/* use TLog dateformat MMM DD YY and grab the 1st 3 chars as the month */
getdateformat
oldformat = result
dateformat 4
/* If you have been making entries into the data base, it is best to */
/* flush its buffers by doing a close first */
'closedb'
/* Open the data base and mark the end record */
'opendb'
'lastrec'
lastdatarecord = result
/* Here the distance field, dbdist, is added to the running total for the */
/* month. The month is found by extracting a substring of the date field,*/
/* dbdate. More sophisticated reports can come from this simple example. */
/* For instance, you can filter out (don't add) any distance that comes */
/* from a record with a particular dbkey, e.g. GOAL, and save them in a */
/* different table. Then print the tables together for comparison. */
/* get the first record and its data */
'firstrec'
/* the fields are delineated with vericle bars '|' */
PARSE var result '"' dbdate '"' dbheart dbdist dbtime dbweight dbtemp dbkey
month = SUBSTR(dbdate,1,3)
total.month = total.month + dbdist
total.YEAR = total.YEAR + dbdist
/* Now loop forever, or until nextrec yields the last record */
DO FOREVER
'nextrec'
/* the fields are delineated with vericle bars '|' */
parse var result '"' dbdate '"' dbheart dbdist dbtime dbweight dbtemp dbkey
month = SUBSTR(dbdate,1,3)
total.month = total.month + dbdist
total.YEAR = total.YEAR + dbdist
if result = lastdatarecord then BREAK
END
/* restore the date format */
dateformat oldformat
/* Now generate your reports; or pass the data to spread sheet or graphics */
/* program that has an AREXX interface. You might even have scripts that */
/* do bar charts in AREXX already. For now we'll keep it simple ... */
/* print out our monthly totals */
say "Total distances by month:"
say JAN total.JAN
say FEB total.FEB
say MAR total.MAR
say APR total.APR
say MAY total.MAY
say JUN total.JUN
say JUL total.JUL
say AUG total.AUG
say SEP total.SEP
say OCT total.OCT
say NOV total.NOV
say DEC total.DEC
say"---------"
say "TOT" total.YEAR